package org.springblade.modules.admin.controller;

import com.aliyun.oss.ServiceException;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.admin.dto.RescueArriveDTO;
import org.springblade.modules.admin.service.IMaintainMalfunctionRescueService;
import org.springblade.modules.admin.service.IMaintainPlanContentService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 救援已到达Controller
 * @author: Sharry
 * @createTime: 2023/6/8 14:21
 * @version: Version-1.0
 */
@RestController
@Api(tags = "救援已到达控制器" , value = "admin/maintain/malfunction/rescue/arrive")
@AllArgsConstructor
@RequestMapping("admin/maintain/malfunction/rescue/arrive")
public class RescueArriveController {

	private final IMaintainMalfunctionRescueService mmrService;

	@PostMapping("/confirm")
	@ApiOperation("确认已到达")
	@ApiOperationSupport(order = 10)
	public R<Boolean> confirm(@RequestBody RescueArriveDTO arriveRequest){
		// 参数校验
		Long userId = arriveRequest.getUserId();
		Long planId = arriveRequest.getPlanId();
		if(Func.isNull(userId) || Func.isNull(planId)){
			throw new ServiceException("确认失败，参数不完整！");
		}
		// 业务处理
		boolean confirmResult = mmrService.rescueConfirm(userId,planId);
		return R.data(confirmResult);
	}
}
